﻿@using Beaver
@using Beaver.Areas.Identity.Models
@using Beaver.Dtos.BingWallpaper
@using Beaver.Models
@inject IWebHostEnvironment webHostEnvironment
@model LoginModel
@{
    Layout = null;
    var account = Model?.UserName;
    if (string.IsNullOrWhiteSpace(account))
    {
        account = webHostEnvironment.IsDevelopment() ? "admin" : string.Empty;
    }
    BingImage bgImg;
    if (ViewBag.LoginImage is BingImage bingImage)
    {
        bgImg = bingImage;
    }
    else
    {
        //默认壁纸
        bgImg = new BingImage
        {
            Fullstartdate = "202507251600",
            Url = "/image/index_fullbg.jpg",
            Urlbase = "/image/index_fullbg.jpg",
            Copyright = "黄昏时的红树林，瓦拉基里海滩，松巴岛，印度尼西亚 (© Boonchet Ch./Getty Images)",
            Copyrightlink = "https://www.bing.com/search?q=%E4%BF%9D%E6%8A%A4%E7%BA%A2%E6%A0%91%E6%9E%97%E7%94%9F%E6%80%81%E7%B3%BB%E7%BB%9F%E5%9B%BD%E9%99%85%E6%97%A5&form=hpcapt&mkt=zh-cn",
            Title = "潮汐的守护者",
        };
    }
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录 - 小狸影视</title>
    <environment include="Development">
        <link href="~/lib/layui/css/layui.css" rel="stylesheet" asp-append-version="true" />
    </environment>
    <environment exclude="Development">
        <link href="~/lib/layui/css/layui.min.css" rel="stylesheet" asp-append-version="true" />
    </environment>
    <link href="~/lib/layui-theme-dark/dist/layui-theme-dark-selector.css" rel="stylesheet" asp-append-version="true" />
    <style>
        body {
            background-image: url('@bgImg.Url');
            background-size: cover;
            background-position: center;
            background-attachment: fixed;
            background-repeat: no-repeat;
        }

        .center-div {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 400px;
            opacity: 0.98;
        }

        .w3-padding-large {
            padding: 12px 24px !important;
        }

        .w3-display-bottomleft {
            position: absolute;
            left: 0;
            bottom: 0;
        }

        .w3-xlarge {
            font-size: 24px !important;
            color: #fff !important;
        }

        .w3-large {
            font-size: 18px !important;
            color: #fff !important;
            margin-top: 0px;
        }

    </style>
</head>
<body>
    <div class="layui-card center-div">
        <div class="layui-card-header">登录&nbsp;<span class="layui-badge layui-bg-blue @(webHostEnvironment.IsDevelopment() ? string.Empty : "layui-hide")">Beta</span></div>
        <div class="layui-card-body">
            <form class="layui-form" asp-action="Login" method="post">
                <div class="layui-form-item">
                    <div class="layui-input-wrap">
                        <div class="layui-input-prefix">
                            <i class="layui-icon layui-icon-username"></i>
                        </div>
                        <input type="text" asp-for="UserName" value=@account lay-verify="required" placeholder="用户名" lay-reqtext="请填写用户名" autocomplete="off" class="layui-input" lay-affix="clear">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-wrap">
                        <div class="layui-input-prefix">
                            <i class="layui-icon layui-icon-password"></i>
                        </div>
                        <input type="password" asp-for="Password" lay-verify="required" placeholder="密   码" lay-reqtext="请填写密码" autocomplete="off" class="layui-input" lay-affix="eye">
                    </div>
                </div>
                <div class="layui-form-item">
                    <input type="checkbox" asp-for="RememberMe" lay-skin="primary" title="记住密码">
                </div>
                <div class="layui-form-item layui-hide">
                    <input type="text" asp-for="ReturnUrl" value="@ViewData["ReturnUrl"]" lay-skin="primary" title="回调页面">
                </div>
                <div class="layui-form-item">
                    <div asp-validation-summary="All" style="color: #ff5722"></div>
                </div>
                <div class="layui-form-item">
                    @Html.AntiForgeryToken()
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-login">登录</button>
                </div>
            </form>
        </div>
    </div>

    <div class="w3-display-bottomleft w3-padding-large">
        <h1 class="w3-xlarge">@(DateTime.ParseExact(bgImg.Fullstartdate, "yyyyMMddHHmm", null).ToShortDateString())，@bgImg.Title</h1>
        <a class="w3-large" href="@bgImg.Copyrightlink" target="_blank">@bgImg.Copyright</a>
    </div>

    <environment include="Development">
        <script src="~/lib/layui/layui.js" asp-append-version="true"></script>
    </environment>
    <environment exclude="Development">
        <script src="~/lib/layui/layui.min.js" asp-append-version="true"></script>
    </environment>
    <partial name="_DarkScriptPartial" />
    <partial name="_BaiduStatisticsScriptsPartial" />
    <script type="text/javascript" asp-append-version="true">
        layui.use(function () {
            var form = layui.form;
            var layer = layui.layer;
        });
    </script>
</body>
</html>
